package com.estylesoft.pshevch.tests;

import com.estylesoft.pshevch.model.MovieData;
import org.testng.annotations.*;
import static org.junit.Assert.*;

import org.openqa.selenium.*;

public class AddMovieTestPack extends com.estylesoft.pshevch.tests.TestBase {

    @Test
    public void testValidMovieCreation() throws Exception {

        MovieData movieData = new MovieData()
                .withImdbId("1234567890")
                .withName("Movie Name")
                .withAka("Also known as")
                .withYear("1998")
                .withDuration("100")
                .withRating("10")
                .withCoverPath("D:\\temp\\full\\qnQ7T.jpg")
                .withTrailerUrl("http://url.trailer.com")
                .withNotes("Notes")
                .withTaglines("Taglines")
                .withPlotOutline("Plot Outline")
                .withPlots("Plots")
                .withLanguages("Languages")
                .withSubtitles("Subtitles")
                .withAudio("Audio")
                .withVideo("Video")
                .withCountry("Country")
                .withGenres("Genres")
                .withDirector("Director")
                .withWriter("Writer")
                .withProducer("Producer")
                .withMusic("Music")
                .withCast("Cast")
                .withOwnFlag(false)
                .withSeenFlag(false)
                .withLoanedFlag(true);

        appManager.getMovieHelper().addMovie(movieData);

        appManager.getNavigationHelper().homePage();

    }

    @Test
    public void testInvalidMovieCreationNoTitle() throws Exception {

        MovieData movieData = new MovieData()
                .withImdbId("1234567890")
                .withName("") // With empty name!
                .withAka("Also known as")
                .withYear("1998")
                .withDuration("100")
                .withRating("10")
                .withCoverPath("D:\\temp\\full\\qnQ7T.jpg")
                .withTrailerUrl("http://url.trailer.com")
                .withNotes("Notes")
                .withTaglines("Taglines")
                .withPlotOutline("Plot Outline")
                .withPlots("Plots")
                .withLanguages("Languages")
                .withSubtitles("Subtitles")
                .withAudio("Audio")
                .withVideo("Video")
                .withCountry("Country")
                .withGenres("Genres")
                .withDirector("Director")
                .withWriter("Writer")
                .withProducer("Producer")
                .withMusic("Music")
                .withCast("Cast")
                .withOwnFlag(false)
                .withSeenFlag(false)
                .withLoanedFlag(true);

        appManager.getMovieHelper().addMovie(movieData);

        String verificationMessage = appManager.getMovieHelper().getVerificationMessage("Title");

        assertEquals(verificationMessage, "This field is required");

        appManager.getNavigationHelper().homePage();

    }

    @Test
    public void testInvalidMovieCreationNoYear() throws Exception {

        MovieData movieData = new MovieData()
                .withImdbId("1234567890")
                .withName("Movie Name")
                .withAka("Also known as")
                .withYear("")
                .withDuration("100")
                .withRating("10")
                .withCoverPath("D:\\temp\\full\\qnQ7T.jpg")
                .withTrailerUrl("http://url.trailer.com")
                .withNotes("Notes")
                .withTaglines("Taglines")
                .withPlotOutline("Plot Outline")
                .withPlots("Plots")
                .withLanguages("Languages")
                .withSubtitles("Subtitles")
                .withAudio("Audio")
                .withVideo("Video")
                .withCountry("Country")
                .withGenres("Genres")
                .withDirector("Director")
                .withWriter("Writer")
                .withProducer("Producer")
                .withMusic("Music")
                .withCast("Cast")
                .withOwnFlag(false)
                .withSeenFlag(false)
                .withLoanedFlag(true);

        appManager.getMovieHelper().addMovie(movieData);

        String verificationMessage = appManager.getMovieHelper().getVerificationMessage("Year");

        assertEquals(verificationMessage, "This field is required");

        appManager.getNavigationHelper().homePage();

    }
}
